package com.zhejiangzhengyuan.municipal_sewage.controller;

import com.zhejiangzhengyuan.municipal_common.annotation.AuthorizationLess;
import com.zhejiangzhengyuan.municipal_common.response.ResponseVo;
import com.zhejiangzhengyuan.municipal_common.service.ManholeCoverApplicationService;
import com.zhejiangzhengyuan.municipal_common.service.ProblemsService;
import com.zhejiangzhengyuan.municipal_common.utils.ConstantUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author lin_ju
 * @since on 2019/11/25 description: 测试井盖物联网数据
 */
@RestController
@Api(tags = "测试井盖物联网数据")
@RequestMapping("/sewage/monitorDevice")
public class SewageMonitorDeviceController {
  @Autowired private ManholeCoverApplicationService applicationService;
  @Autowired private ProblemsService problemsService;

  private String DeviceType = ConstantUtil.DEVICE_TYPE.SEWAGE;
  @AuthorizationLess
  @ApiOperation(value = "收取井盖设备指令集")
  @RequestMapping(value = "/operationResult", method = RequestMethod.POST)
  public void operationResult(HttpServletRequest request) throws Exception {
    applicationService.fromDeviceResult(request, DeviceType);
  }
  @AuthorizationLess
  @ApiOperation(value = "井盖物联网设备检测是否上线")
  @RequestMapping(value = "/isOnline", method = RequestMethod.POST)
  public void isOnline(HttpServletRequest request) throws Exception {
    applicationService.isOnline(request, DeviceType);
  }

  @ApiOperation("积水点信息")
  @GetMapping("/selectProblems")
  public ResponseVo selectProblemsCharts(Integer month) {
    month = month == null ? 1 : month;
    return problemsService.selectProblemsCharts(month);
  }

  @ApiOperation("整改积水点信息")
  @GetMapping("/selectRectifySewage")
  public ResponseVo selectRectifySewage(Integer month) {
    month = month == null ? 1 : month;
    return problemsService.selectRectifySewage(month);
  }
}
